/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.26                          *
*        Compiled Aug 18 2014, 17:12:05                              *
*        (c) 2014 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"
#include "WindowDLG.h"




/*********************************************************************
*
*                        外部引用
*
**********************************************************************
*/
extern OS_TCB   AppTaskWindowTCB;
extern OS_TCB   AppTaskShowBQTCB;

extern u8 Touch_TimeMode;
extern u8 settime_mode;

extern const unsigned char _acbeijing[43783UL + 1];
extern GUI_CONST_STORAGE GUI_BITMAP bmspeaker;
extern GUI_CONST_STORAGE GUI_BITMAP bmsetting;
extern GUI_CONST_STORAGE GUI_BITMAP bmplanner;
extern GUI_CONST_STORAGE GUI_BITMAP bmmusic;
extern GUI_CONST_STORAGE GUI_BITMAP bmfolder;
extern GUI_CONST_STORAGE GUI_BITMAP bmcamera;
extern GUI_CONST_STORAGE GUI_BITMAP bmarmclock;
extern GUI_CONST_STORAGE GUI_BITMAP bmabout;
extern GUI_CONST_STORAGE GUI_BITMAP bmundo;

extern GUI_CONST_STORAGE GUI_BITMAP bmzd;
extern GUI_CONST_STORAGE GUI_BITMAP bmstop;
extern GUI_CONST_STORAGE GUI_BITMAP bmbegin;




/*********************************************************************
* 
*                               Defines
*
**********************************************************************
*/

#define ID_WINDOW_0   (GUI_ID_USER + 0x00)
#define ID_DROPDOWN_0   (GUI_ID_USER + 0x01)
#define ID_DROPDOWN_1   (GUI_ID_USER + 0x02)
#define ID_DROPDOWN_2   (GUI_ID_USER + 0x03)
#define ID_DROPDOWN_3   (GUI_ID_USER + 0x04)
#define ID_DROPDOWN_4   (GUI_ID_USER + 0x05)
#define ID_BUTTON_0   (GUI_ID_USER + 0x06)
#define ID_BUTTON_1   (GUI_ID_USER + 0x07)
#define ID_TEXT_0   (GUI_ID_USER + 0x08)
#define ID_TEXT_1   (GUI_ID_USER + 0x09)
#define ID_TEXT_2   (GUI_ID_USER + 0x0A)
#define ID_TEXT_3   (GUI_ID_USER + 0x0B)
#define ID_TEXT_4   (GUI_ID_USER + 0x0C)

/*          以下定义用于主设置界面                   */
#define ID_WINDOW_1   (GUI_ID_USER + 0x0D)
#define ID_TEXT_5   (GUI_ID_USER + 0x0E)
#define ID_TEXT_6   (GUI_ID_USER + 0x0F)
#define ID_TEXT_7   (GUI_ID_USER + 0x10)


#define ID_TimerTime 1

#define _DF1S                   0x81
#define MUSIC_MAX_NUM           100
#define FILE_NAME_LEN           101			
#define MUSIC_NAME_LEN          51		

/*********************************************************************
*
*                                变量和数组
*
**********************************************************************
*/
WM_HWIN hWin2;
WM_HWIN hWinICON;
WM_HWIN hWinMain;
WM_HWIN hWinInfo;
WM_HWIN hWinInfo2;
GUI_MEMDEV_Handle    hMempic;

u8	s_ucSelIconIndex = 0;	/* 选择的ICON，默认不选择任何 */
Rtime Wset;

/* 用于桌面ICONVIEW图标的创建 */
typedef struct 
{
	const GUI_BITMAP * pBitmap;
	const char       * pText;
} BITMAP_ITEM;

/* 用于桌面ICONVIEW图标的创建 */
static const BITMAP_ITEM _aBitmapItem[] = 
{
	{&bmarmclock,    "Clock"},
	{&bmmusic,    "Music"},
	{&bmcamera,    "Camera"},
	{&bmplanner,    "Planner"},
	
	{&bmspeaker,    "Speaker"},
	{&bmfolder,    "Folder"},
	{&bmsetting,    "Setting"},
	{&bmabout,    "About"},
	{&bmundo,     "Back"},
};



///* 用于MUSIC ICONVIEW图标的创建 */
//static const BITMAP_ITEM _aBitmapMusicItem[] = 
//{
//	{&bmbegin,    "Begin"},
//	{&bmzd,    "Suspend"},
//	{&bmstop,     "Stop"},
//};

int volume,list_value = 0;
int last_data = 0;

static char path[100]="0:";																		
static uint8_t  file_num = 0;					
static unsigned char playlist[MUSIC_MAX_NUM][FILE_NAME_LEN];
static unsigned char lcdlist[MUSIC_MAX_NUM][MUSIC_NAME_LEN];



/*
*********************************************************************************************************
*	函 数 名: Caculate_RTC
*	功能说明: 显示RTC时间   未使用
*	形    参: pMsg 指针参数            
*	返 回 值: 无
*********************************************************************************************************
*/
static void Caculate_RTC(WM_MESSAGE * pMsg)
{
	  char buf[30];
	  WM_HWIN hWin = pMsg->hWin;
      
	 RTC_TimeTypeDef  RTC_TimeStructure;
     RTC_DateTypeDef  RTC_DateStructure;
	
	  RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
	  RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);

	  sprintf(buf, 
	          "%d:%d:%d", 
			  RTC_TimeStructure.RTC_Hours, 
			  RTC_TimeStructure.RTC_Minutes,
			  RTC_TimeStructure.RTC_Seconds);
	 TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_6), buf);
 
	  sprintf(buf, 
	          "20%d/%d/%d", 
			  RTC_DateStructure.RTC_Year, 
			  RTC_DateStructure.RTC_Month, 
			  RTC_DateStructure.RTC_Date);
	  TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_7), buf); 			  	          
}

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0,0, 480, 272, 0, 0x0, 0 },
  { DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_0, 112, 68, 85, 19, 0, 0x0, 0 },
  { DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_1, 222, 68, 60, 19, 0, 0x0, 0 },
  { DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_2, 307, 68, 60, 19, 0, 0x0, 0 },
  { DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_3, 152, 140, 60, 19, 0, 0x0, 0 },
  { DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_4, 268, 140, 60, 19, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 118, 207, 80, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 253, 209, 80, 20, 0, 0x0, 0 },
  
  { TEXT_CreateIndirect, "Year", ID_TEXT_0, 112,48,120,19, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Month", ID_TEXT_1, 222,48,120,19, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "DATE", ID_TEXT_2, 307,48,120,19, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "HOURS", ID_TEXT_3, 152,120,120,19, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "MINUTES", ID_TEXT_4, 268,120,120,19, 0, 0x0, 0 },
};


/*********************************************************************
*
*       _aDialogCreate2
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_1, 0, 0, 480, 272, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_5, 180,7,120,19, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_6, 380,7,120,19, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_7, 300,7,120,19, 0, 0x0, 0 },
};

/*********************************************************************
*
*       _aDialogCreate3
*/


static const GUI_WIDGET_CREATE_INFO _aDialogCreate3[] = {
    { FRAMEWIN_CreateIndirect,  "Caption",           0,                       0,  0,  480,272,0,0},
    { TEXT_CreateIndirect,    "It designed by OJ",           GUI_ID_TEXT0,          80,20,248,32, 0,0},
	{ TEXT_CreateIndirect,    "UCOS Version  UCOS-III",           GUI_ID_TEXT1,          80,57,248,32, 0,0},
	{ TEXT_CreateIndirect,    "EMWIN Version  V5.40",           GUI_ID_TEXT2,          80,94,248,32, 0,0},
	{ TEXT_CreateIndirect,    "FILE System  FATFS",           GUI_ID_TEXT3,          80,131,248,32, 0,0},
	{ TEXT_CreateIndirect,    "SYSTEM Version  V1.0",           GUI_ID_TEXT4,          80,168,248,32, 0,0},
	{ TEXT_CreateIndirect,    "DATE  2018-11-15",           GUI_ID_TEXT6,          80,205,248,32, 0,0},
};
/*********************************************************************111
*
*       _aDialogCreate4
*/


static const GUI_WIDGET_CREATE_INFO _aDialogCreate4[] = {
    { FRAMEWIN_CreateIndirect,  "Caption",           0,                       0,  0,  480,272,0,0},
      { TEXT_CreateIndirect, "TALK", GUI_ID_TEXT0, 27, 24, 39, 19, 0, 0x0, 0 },
	  { BUTTON_CreateIndirect, "OK", GUI_ID_BUTTON0, 181, 178, 80, 20, 0, 0x0, 0 },
	  { TEXT_CreateIndirect, "Program", GUI_ID_TEXT1, 223, 27, 80, 20, 0, 0x0, 0 },
	  { CHECKBOX_CreateIndirect, "CheckPeople", GUI_ID_CHECK0, 278, 24, 97, 20, 0, 0x0, 0 },
	  { CHECKBOX_CreateIndirect, "Power", GUI_ID_CHECK1, 278, 57, 80, 20, 0, 0x0, 0 },
	  { CHECKBOX_CreateIndirect, "Light", GUI_ID_CHECK2, 278, 90, 80, 20, 0, 0x0, 0 },
	  { DROPDOWN_CreateIndirect, "Dropdown", GUI_ID_DROPDOWN0, 67, 23, 100, 18, 0, 0x0, 0 },
	  { TEXT_CreateIndirect, "Volume", GUI_ID_TEXT3, 27, 96, 42, 18, 0, 0x0, 0 },
      { SLIDER_CreateIndirect, "Slider", GUI_ID_SLIDER0, 69, 91, 80, 20, 0, 0x0, 0 },
};

/*********************************************************************111
*
*       _aDialogCreate5
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate5[] = 
{
    { FRAMEWIN_CreateIndirect,    "SD FILE",        0,             0,   0,  480, 272 ,  0},
    { LISTVIEW_CreateIndirect,     NULL,          GUI_ID_LISTVIEW0,   0,   0,470, 220,  0, 0},
};

/*********************************************************************111
*
*       _aDialogCreate6
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate6[] = 
{
    { FRAMEWIN_CreateIndirect,    "MUSIC",        0,             0,   0,  480, 272 ,  0},
	 { BUTTON_CreateIndirect, "PLAY", GUI_ID_BUTTON0, 32, 110, 80, 20, 0, 0x0, 0 },
	  { BUTTON_CreateIndirect, "STOP", GUI_ID_BUTTON1, 151, 110, 80, 20, 0, 0x0, 0 },
	   { BUTTON_CreateIndirect, "Suspend", GUI_ID_BUTTON2, 273, 110, 80, 20, 0, 0x0, 0 },
	    { BUTTON_CreateIndirect, "Resume", GUI_ID_BUTTON3, 393, 110, 80, 20, 0, 0x0, 0 },
};


/*********************************************************************111
*
*       _aDialogCreate7
*/


static const GUI_WIDGET_CREATE_INFO _aDialogCreate7[] = {
    { FRAMEWIN_CreateIndirect,  "Volume",           0,  0,  0,  480,272,0,0},
  { SLIDER_CreateIndirect, "Slider", GUI_ID_SLIDER0, 125, 93, 216, 60, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Edit", GUI_ID_TEXT0, 195, 60, 80, 20, 0, 0x64, 0 },
  { BUTTON_CreateIndirect, "Button", GUI_ID_BUTTON0, 194, 180, 80, 20, 0, 0x0, 0 },
};

static const GUI_WIDGET_CREATE_INFO _aDialogProgress[] = {
  { FRAMEWIN_CreateIndirect, "In Progress...",  0,                 100,  100, 150,  60, 0 },
  { PROGBAR_CreateIndirect,  0,                 GUI_ID_PROGBAR0,    9,   6, 120,  20, 0 },
};







/**
  * @brief  scan_files 递归扫描sd卡内的歌曲文件
  * @param  path:初始扫描路径
  * @retval result:文件系统的返回值
  */
static FRESULT scan_files (char* path) 
{ 
  FRESULT res; 		//部分在递归过程被修改的变量，不用全局变量	
  FILINFO fno; 
  DIR dir; 
  int i; 
  char *fn; 
	char file_name[FILE_NAME_LEN];	
	
#if _USE_LFN 
  static char lfn[_MAX_LFN * (_DF1S ? 2 : 1) + 1]; 	//长文件名支持
  fno.lfname = lfn; 
  fno.lfsize = sizeof(lfn); 
#endif 

  
  res = f_opendir(&dir, path); //打开目录
  if (res == FR_OK) 
	{ 
    i = strlen(path); 
    for (;;) 
		{ 
      res = f_readdir(&dir, &fno); 										//读取目录下的内容
      if (res != FR_OK || fno.fname[0] == 0) break; 	//为空时表示所有项目读取完毕，跳出
#if _USE_LFN 
      fn = *fno.lfname ? fno.lfname : fno.fname; 
#else 
      fn = fno.fname; 
#endif 
      if(strstr(path,"recorder")!=NULL)continue;       //逃过录音文件
      if (*fn == '.') continue; 											//点表示当前目录，跳过			
      if (fno.fattrib & AM_DIR) 
			{ 																							//目录，递归读取
        sprintf(&path[i], "/%s", fn); 							//合成完整目录名
        res = scan_files(path);											//递归遍历 
        if (res != FR_OK) 
					break; 																		//打开失败，跳出循环
        path[i] = 0; 
      } 
			else 
			{ 
//				Debug_printf("%s/%s\r\n", path, fn);								//输出文件名
						sprintf(file_name, "%s/%s", path, fn);
				        memcpy(playlist[file_num],file_name,strlen(file_name));
						memcpy(lcdlist[file_num],fn,strlen(fn));						
						file_num++;//记录文件个数
      }//else
    } //for
  } 
  return res; 
}





/*********************************************************************
*
*       _cbDialogProgress
*/
static void _cbDialogProgress(WM_MESSAGE * pMsg) {
  static int Progress;
  WM_HWIN    hWin;
  WM_HWIN    hItem;
  char ONE_BIT = 1;
  hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_SetBkColor(GUI_WHITE);
    GUI_Clear();
    break;
  case WM_TIMER:
    if (Progress < 100) {
      Progress += 2;
      hItem = WM_GetDialogItem(hWin, GUI_ID_PROGBAR0);
      PROGBAR_SetValue(hItem, Progress);
      WM_RestartTimer(pMsg->Data.v, 20);
    } else {
	  ONE_BIT = 1;
      WM_DeleteTimer(pMsg->Data.v);
      GUI_MEMDEV_FadeOutWindow(pMsg->hWin, 500);
      GUI_EndDialog(pMsg->hWin, 0);
    }
    break;
  case WM_INIT_DIALOG:
    Progress = 0;
    FRAMEWIN_SetMoveable(hWin, 1);
    WM_CreateTimer(WM_GetClientWindow(hWin), 0, 200, 0);
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}





/*********************************************************************
*
*       _cbDialogProgress
*/
static void _cbDialogProgress1(WM_MESSAGE * pMsg) {
  static int Progress;
  WM_HWIN    hWin;
  WM_HWIN    hItem;
  char ONE_BIT = 1;
  hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_SetBkColor(GUI_WHITE);
    GUI_Clear();
    break;
  case WM_TIMER:
    if (Progress < 100) {
      Progress += 2;
      hItem = WM_GetDialogItem(hWin, GUI_ID_PROGBAR0);
      PROGBAR_SetValue(hItem, Progress);
      WM_RestartTimer(pMsg->Data.v, 20);
    } else {
	  ONE_BIT = 1;
      WM_DeleteTimer(pMsg->Data.v);
      GUI_MEMDEV_FadeOutWindow(pMsg->hWin, 500);
      GUI_EndDialog(pMsg->hWin, 0);
    }
    break;
  case WM_INIT_DIALOG:
    Progress = 0;
    FRAMEWIN_SetMoveable(hWin, 1);
    WM_CreateTimer(WM_GetClientWindow(hWin), 0, 200, 0);
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}


/*
*********************************************************************************************************
*	函 数 名: _cbCallback1
*	功能说明: 回调函数
*	形    参: pMsg 指针参数            
*	返 回 值: 无
*********************************************************************************************************
*/
static void _cbCallback1(WM_MESSAGE * pMsg) 
{
    int NCode, Id;
    WM_HWIN hWin = pMsg->hWin;
	
    switch (pMsg->MsgId) 
    {
        case WM_INIT_DIALOG:
			
			/*
			*    初始化框架窗口
		    */
			FRAMEWIN_SetFont(hWin,GUI_FONT_20B_ASCII);
			FRAMEWIN_SetText(hWin, _aBitmapItem[s_ucSelIconIndex].pText);
			FRAMEWIN_SetTextAlign(hWin,GUI_TA_VCENTER|GUI_TA_CENTER);
			FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
			FRAMEWIN_SetTitleHeight(hWin, 36);
            break;
		
        case WM_KEY:
            switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) 
            {
                case GUI_KEY_ESCAPE:
                    GUI_EndDialog(hWin, 1);
                    break;
				
                case GUI_KEY_ENTER:
                    GUI_EndDialog(hWin, 0);
                    break;
            }
            break;
			
        case WM_NOTIFY_PARENT:
            Id = WM_GetId(pMsg->hWinSrc); 
            NCode = pMsg->Data.v;        
            switch (Id) 
            {
//                case GUI_ID_OK:
//                    if(NCode==WM_NOTIFICATION_RELEASED)
//					{
//						GUI_EndDialog(hWin, 0);					
//					}
//                    break;
//					
//                case GUI_ID_CANCEL:
//                    if(NCode==WM_NOTIFICATION_RELEASED)
//					{
//						GUI_EndDialog(hWin, 0);	
//					}
//                    break;

            }
            break;
			
        default:
            WM_DefaultProc(pMsg);
    }
}




/*
*********************************************************************************************************
*	函 数 名: _cbCallback2
*	功能说明: 回调函数
*	形    参: pMsg 指针参数            
*	返 回 值: 无
*********************************************************************************************************
*/
static void _cbCallback2(WM_MESSAGE * pMsg) 
{
	WM_HWIN hItem;
	WM_HWIN hProg;
    int NCode, Id;
	u8 light = 1,check = 1,power = 1;
    WM_HWIN hWin = pMsg->hWin;
	
    switch (pMsg->MsgId) 
    {
        case WM_INIT_DIALOG:
			
			/*
			*    初始化框架窗口
		    */
			FRAMEWIN_SetFont(hWin,GUI_FONT_20B_ASCII);
			FRAMEWIN_SetText(hWin, _aBitmapItem[s_ucSelIconIndex].pText);
			FRAMEWIN_SetTextAlign(hWin,GUI_TA_VCENTER|GUI_TA_CENTER);
		
			FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
			FRAMEWIN_SetTitleHeight(hWin, 36);
		
		    hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_DROPDOWN0);
			DROPDOWN_SetFont(hItem, GUI_FONT_16B_ASCII);
			DROPDOWN_AddString(hItem, "Chat");
			DROPDOWN_AddString(hItem, "Housekeeper");
		   
		    DROPDOWN_SetAutoScroll(hItem, 1);
			DROPDOWN_SetListHeight(hItem, 80);
			DROPDOWN_SetScrollbarWidth(hItem, 60);
		
		    hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CHECK0);
			CHECKBOX_SetText(hItem,"Light");
			CHECKBOX_SetFont(hItem,GUI_FONT_16B_ASCII);
			CHECKBOX_Check(hItem);
			
			 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CHECK1);
			CHECKBOX_SetText(hItem,"CheckPeople");
			CHECKBOX_SetFont(hItem,GUI_FONT_16B_ASCII);
			CHECKBOX_Check(hItem);
			
			 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CHECK2);
			CHECKBOX_SetText(hItem,"Power");
			CHECKBOX_SetFont(hItem,GUI_FONT_16B_ASCII);
			CHECKBOX_Check(hItem);
			
			hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SLIDER0);
			SLIDER_SetNumTicks(hItem,10);                 //十级音量控制
			SLIDER_SetRange(hItem,0,9);
			
		   
            break;
		
        case WM_KEY:
            switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) 
            {
                case GUI_KEY_ESCAPE:
                    GUI_EndDialog(hWin, 1);
                    break;
				
                case GUI_KEY_ENTER:
                    GUI_EndDialog(hWin, 0);
                    break;
            }
            break;
			
        case WM_NOTIFY_PARENT:
            Id = WM_GetId(pMsg->hWinSrc); 
            NCode = pMsg->Data.v;        
            switch (Id) 
            {
                case GUI_ID_OK:
                    if(NCode==WM_NOTIFICATION_RELEASED)
					{
						GUI_EndDialog(hWin, 0);					
					}
                    break;
					
                case GUI_ID_CANCEL:
                    if(NCode==WM_NOTIFICATION_RELEASED)
					{
						GUI_EndDialog(hWin, 0);	
					}
                    break;
					
				case GUI_ID_SLIDER0:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
						    break;
						case WM_NOTIFICATION_VALUE_CHANGED:
							hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SLIDER0);
						    volume = SLIDER_GetValue(hItem);
							break;
					}break;
				case GUI_ID_CHECK0:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
						    break;
						case WM_NOTIFICATION_VALUE_CHANGED:
							light = ~light;	
							break;
					}break;
				case GUI_ID_CHECK1:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
						    break;
						case WM_NOTIFICATION_VALUE_CHANGED:
							check = ~check;	
							break;
					}break;
				case GUI_ID_CHECK2:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
						    break;
						case WM_NOTIFICATION_VALUE_CHANGED:
							power = ~power;	
							break;
					}break;
				case GUI_ID_DROPDOWN0:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
						    break;
						case WM_NOTIFICATION_VALUE_CHANGED:
							  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_2);
							  list_value =  DROPDOWN_GetSel(hItem);
							break;
					}break;
				case GUI_ID_BUTTON0:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:

							break;
						case WM_NOTIFICATION_RELEASED:
						    hProg = GUI_CreateDialogBox(_aDialogProgress, GUI_COUNTOF(_aDialogProgress), &_cbDialogProgress, WM_HBKWIN, 0, 0); 
							GUI_MEMDEV_FadeInWindow(hProg, 500);
							WM_InvalidateWindow(hWin);
							WM_MakeModal(hProg);
							GUI_ExecCreatedDialog(hProg);
						    break;
					}break;

            }
            break;
			
        default:
            WM_DefaultProc(pMsg);
    }
}


/*
*********************************************************************************************************
*	函 数 名: InitDialogText
*	功能说明: 初始化函数 
*	形    参: pMsg   消息指针变量
*	返 回 值: 无
*********************************************************************************************************
*/


static void _cbCallback3(WM_MESSAGE * pMsg) 
{
    int NCode, Id;
	char i = 0;
	char buf[100];
    WM_HWIN hWin = pMsg->hWin;
	WM_HWIN hItem;
	HEADER_Handle hHeader;
	SCROLLBAR_Handle hScrollbar;
	FILINFO info;
    switch (pMsg->MsgId) 
    {
        case WM_INIT_DIALOG:
			
			/*
			*    初始化框架窗口
		    */

				FRAMEWIN_SetTextColor(hWin, 0x0000ff);
				FRAMEWIN_SetFont(hWin, GUI_FONT_16B_ASCII);
				FRAMEWIN_SetTextAlign(hWin, GUI_TA_VCENTER|GUI_TA_CENTER);
				
				FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
				FRAMEWIN_SetTitleHeight(hWin, 30);

				/* 设置listview控件上的header */
				hHeader = LISTVIEW_GetHeader(WM_GetDialogItem(hWin, GUI_ID_LISTVIEW0));
				HEADER_SetFont(hHeader, GUI_FONT_16B_ASCII);
				HEADER_SetHeight(hHeader, 25);

				/* 设置listview控件上的SCROLLBAR */
				hItem = WM_GetDialogItem(hWin,GUI_ID_LISTVIEW0);
				hScrollbar = SCROLLBAR_CreateAttached(hItem, SCROLLBAR_CF_VERTICAL);
				SCROLLBAR_SetWidth(hScrollbar, 20);

				/* 设置LISTVIEW控件 */
				LISTVIEW_SetFont(hItem, GUI_FONT_16B_ASCII);
				LISTVIEW_SetRowHeight(hItem, 24);
				LISTVIEW_AddColumn(hItem, 20, "NAME", GUI_TA_VCENTER|GUI_TA_LEFT);
				LISTVIEW_AddColumn(hItem, 20, "SIZE", GUI_TA_VCENTER|GUI_TA_LEFT);
				LISTVIEW_SetColumnWidth(hItem, 0, 140);
				LISTVIEW_SetColumnWidth(hItem, 1, 100);
				LISTVIEW_SetGridVis(hItem,1);
				
				file_num = 0;
				scan_files(path);
				
				
				for(i=0;i<file_num;i++)
					{ 
						LISTVIEW_AddRow(hItem, NULL);
						LISTVIEW_SetItemText(hItem, 0, i, (const char *)lcdlist[i]);
						
						f_stat((const char *)playlist[i],&info);
						if(info.fsize < 1024)
							{
								sprintf((char *)buf, "%dB",info.fsize);
							}
							else if(info.fsize < 1024*1024)
							{
								sprintf((char *)buf, "%.2fKB", (float)info.fsize/1024);
							}
							else
							{
								sprintf((char *)buf, "%.2fMB", (float)info.fsize/1024/1024);
							}
							LISTVIEW_SetItemText(hItem, 1, i, (const char *)buf);	
					}
            break;
		
        case WM_KEY:
            switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) 
            {
                case GUI_KEY_ESCAPE:
                    GUI_EndDialog(hWin, 1);
                    break;
				
                case GUI_KEY_ENTER:
                    GUI_EndDialog(hWin, 0);
                    break;
            }
            break;
			
        case WM_NOTIFY_PARENT:
            Id = WM_GetId(pMsg->hWinSrc); 
            NCode = pMsg->Data.v;        
            switch (Id) 
            {


            }
            break;
			
        default:
            WM_DefaultProc(pMsg);
    }
}


static void _cbCallback4(WM_MESSAGE * pMsg) 
{
	WM_HWIN hItem;
	 WM_HWIN hWin = pMsg->hWin;
//	WM_MESSAGE pMsgInfo;
	int NCode, Id;
     OS_ERR      err;
	char i;
	
	switch (pMsg->MsgId) 
	{
		case WM_PAINT:
			break;
		
		case WM_INIT_DIALOG:
			
		      FRAMEWIN_SetTextColor(hWin, GUI_BLACK);
				FRAMEWIN_SetFont(hWin, GUI_FONT_16B_ASCII);
				FRAMEWIN_SetTextAlign(hWin, GUI_TA_VCENTER|GUI_TA_CENTER);
				
				FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
				FRAMEWIN_SetTitleHeight(hWin, 30);
			
			break;
			
		case WM_TIMER:
			break;
			
		case WM_NOTIFY_PARENT:
			Id    = WM_GetId(pMsg->hWinSrc);     
			NCode = pMsg->Data.v;                
			switch (Id) 
			{
				case GUI_ID_BUTTON0:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
							Debug_printf("play\n");
						    GUI_Delay(100);
						    printf("@PlayTF#0003$");
						    break;
					}break;
				case GUI_ID_BUTTON1:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
							GUI_Delay(100);
							printf("@StopPlaying#$");
						    break;
					}break;
				case GUI_ID_BUTTON2:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
							GUI_Delay(100);
							printf("@PausePlaying#$");
						    break;
					}break;
				case GUI_ID_BUTTON3:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
							GUI_Delay(100);
							printf("@ReplyPlaying#$");
						    break;
					}break;

			}
			break;
			
		default:
			WM_DefaultProc(pMsg);
	}
}



static void _cbCallback5(WM_MESSAGE * pMsg) 
{
	WM_HWIN hItem;
	WM_HWIN hProg;
    int NCode, Id;
	char buffer[50];
    WM_HWIN hWin = pMsg->hWin;
	
    switch (pMsg->MsgId) 
    {
        case WM_INIT_DIALOG:
			
			/*
			*    初始化框架窗口
		    */
			FRAMEWIN_SetFont(hWin,GUI_FONT_20B_ASCII);
			FRAMEWIN_SetText(hWin, _aBitmapItem[s_ucSelIconIndex].pText);
			FRAMEWIN_SetTextAlign(hWin,GUI_TA_VCENTER|GUI_TA_CENTER);
		
			FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
			FRAMEWIN_SetTitleHeight(hWin, 36);
		
		    hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT0);
			sprintf((char *)buffer,"Volume = %d",volume);
			TEXT_SetText(hItem,(const char *)buffer);
			
			hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SLIDER0);
			SLIDER_SetNumTicks(hItem,10);                 //十级音量控制
			SLIDER_SetRange(hItem,0,9);
		    SLIDER_SetValue(hItem,volume);
			
		   
            break;
		
        case WM_KEY:
            switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) 
            {
                case GUI_KEY_ESCAPE:
                    GUI_EndDialog(hWin, 1);
                    break;
				
                case GUI_KEY_ENTER:
                    GUI_EndDialog(hWin, 0);
                    break;
            }
            break;
			
        case WM_NOTIFY_PARENT:
            Id = WM_GetId(pMsg->hWinSrc); 
            NCode = pMsg->Data.v;        
            switch (Id) 
            {
                case GUI_ID_OK:
                    if(NCode==WM_NOTIFICATION_RELEASED)
					{
						GUI_EndDialog(hWin, 0);					
					}
                    break;
					
                case GUI_ID_CANCEL:
                    if(NCode==WM_NOTIFICATION_RELEASED)
					{
						GUI_EndDialog(hWin, 0);	
					}
                    break;
					
				case GUI_ID_SLIDER0:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:
							break;
						case WM_NOTIFICATION_RELEASED:
						    break;
						case WM_NOTIFICATION_VALUE_CHANGED:
							hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SLIDER0);
						    volume = SLIDER_GetValue(hItem);
						    hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT0);
						    sprintf((char *)buffer,"Volume = %d",volume);
						    TEXT_SetText(hItem,(const char *)buffer);
							break;
					}break;
				case GUI_ID_BUTTON0:
					switch(NCode)
					{
						case WM_NOTIFICATION_CLICKED:

							break;
						case WM_NOTIFICATION_RELEASED:
						    Debug_printf("Volume = %d",volume);
						   GUI_Delay(100);
						    printf("@Volume#%d$ ",volume);
						    hProg = GUI_CreateDialogBox(_aDialogProgress, GUI_COUNTOF(_aDialogProgress), &_cbDialogProgress, WM_HBKWIN, 0, 0); 
							GUI_MEMDEV_FadeInWindow(hProg, 500);
							WM_InvalidateWindow(hWin);
							WM_MakeModal(hProg);
							GUI_ExecCreatedDialog(hProg);
						    break;
					}break;

            }
            break;
			
        default:
            WM_DefaultProc(pMsg);
		   break;
    }
}

/*
*********************************************************************************************************
*	函 数 名: _cbDialogInfo
*	功能说明: 主窗口的回调函数
*	形    参：pMsg   参数指针
*	返 回 值: 无
*********************************************************************************************************
*/
static void _cbDialog2(WM_MESSAGE * pMsg) 
{
	WM_HWIN hItem;
//	WM_MESSAGE pMsgInfo;
	int NCode, Id;
     OS_ERR      err;
	char i;
	
	switch (pMsg->MsgId) 
	{
		case WM_PAINT:
			/* 重绘背景图片 */
			GUI_MEMDEV_WriteAt(hMempic,0,0);
			break;
		
		case WM_INIT_DIALOG:
			
		
		   /* 定时消息传递Timer */
	WM_CreateTimer(WM_GetClientWindow(pMsg->hWin), /* 接受信息的窗口的句柄 */
				   ID_TimerTime, 	             /* 用户定义的Id。如果不对同一窗口使用多个定时器，此值可以设置为零。 */
				   20,                           /* 周期，此周期过后指定窗口应收到消息*/
				   0);	                         /* 留待将来使用，应为0 */
			/* 创建文本 */
			hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
			TEXT_SetTextColor(hItem, GUI_WHITE);
			TEXT_SetFont(hItem, GUI_FONT_20B_ASCII);
			TEXT_SetText(hItem, "System Set");

			hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
			TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
			TEXT_SetTextColor(hItem, 0x00FFFFFF);
			TEXT_SetText(hItem, "2014-06-17");
			
			hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
			TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
			TEXT_SetTextColor(hItem, 0x00FFFFFF);
			TEXT_SetText(hItem, "00:00:00");
			break;
			
		case WM_TIMER:
		     Caculate_RTC(pMsg);
			/* 重启定时器 */
			WM_RestartTimer(pMsg->Data.v, 1000);
			break;
			
		case WM_NOTIFY_PARENT:
			Id    = WM_GetId(pMsg->hWinSrc);     
			NCode = pMsg->Data.v;                
			switch (Id) 
			{
				/* 点击ICONVIEW上相应的图标，打开相应的窗口 */
				case GUI_ID_ICONVIEW0:
					switch (NCode) 
					{
						case  WM_NOTIFICATION_RELEASED:
							
							s_ucSelIconIndex  = ICONVIEW_GetSel(pMsg->hWinSrc);
							switch( ICONVIEW_GetSel(pMsg->hWinSrc))
							{
								/* 闹钟设置 */
								case 0:
//									hWinInfo = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbCallback1, 0, 0, 0);				
								    break;	
								
								/* 音乐 */
								case 1:
									Debug_printf("音乐\n");
									hWinInfo2 = GUI_CreateDialogBox(_aDialogCreate6, GUI_COUNTOF(_aDialogCreate6), &_cbCallback4, 0, 0, 0);
                                    				
									break;	
								
								/* 摄像头 */
								case 2:
//									hWinInfo = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbCallback1, 0, 0, 0);				
								    break;	
								
								/* 万年历 */
								case 3:
//									hWinInfo = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbCallback1, 0, 0, 0);				
								    break;
								
								/* 声音 */
								case 4:
									hWinInfo = GUI_CreateDialogBox(_aDialogCreate7, GUI_COUNTOF(_aDialogCreate7), &_cbCallback5, 0, 0, 0);				
								    break;	
								
								/* 文件 */
								case 5:
									hWinInfo = GUI_CreateDialogBox(_aDialogCreate5, GUI_COUNTOF(_aDialogCreate5), &_cbCallback3, 0, 0, 0);				
								    break;	
								
								/* 设置 */
								case 6:
									hWinInfo = GUI_CreateDialogBox(_aDialogCreate4, GUI_COUNTOF(_aDialogCreate4), &_cbCallback2, 0, 0, 0);				
								    break;	
								
								/* 关于 */
								case 7:
									hWinInfo = GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), &_cbCallback1, 0, 0, 0);						
								    break;	
								
								/* 退出 */
								case 8:
									GUI_EndDialog(hWinMain,0);
									settime_mode = 0;
								    Touch_TimeMode = 1 ;
								    OSTaskResume((OS_TCB *)&AppTaskShowBQTCB,&err);
								    break;
								
								default:
									break;
							}	
						 break;
					}
				break;
			}
			break;
			
		default:
			WM_DefaultProc(pMsg);
	}
}

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  WM_HWIN hProg;
   WM_HWIN hWin = pMsg->hWin;
  int     NCode;
  int     Id;
  int     list_value;
 OS_ERR      err;

  switch (pMsg->MsgId) {
	  
	  
	  case WM_PAINT:
	  {
		  /* 重绘背景图片 */
		 GUI_MEMDEV_WriteAt(hMempic,0,0);
	  }break;
  case WM_INIT_DIALOG:
//    hItem = pMsg->hWin;
//    WINDOW_SetBkColor(hItem, GUI_WHITE);
  
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem,"Confirm");
  
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem,"Cancel");
  
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,GUI_FONT_24B_ASCII);
    TEXT_SetText(hItem,"YEAR");
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hItem,GUI_FONT_24B_ASCII);
    TEXT_SetText(hItem,"MONTH");
    
   hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetFont(hItem,GUI_FONT_24B_ASCII);
    TEXT_SetText(hItem,"DATE");
	
	 hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetFont(hItem,GUI_FONT_24B_ASCII);
    TEXT_SetText(hItem,"HOURS");
	
	 hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
    TEXT_SetFont(hItem,GUI_FONT_24B_ASCII);
    TEXT_SetText(hItem,"MINUTES");
    

	hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
	DROPDOWN_SetFont(hItem, GUI_FONT_24B_ASCII);
	DROPDOWN_AddString(hItem, "2016");
	DROPDOWN_AddString(hItem, "2017");
	DROPDOWN_AddString(hItem, "2018");
	DROPDOWN_AddString(hItem, "2019");
	DROPDOWN_AddString(hItem, "2020");

	
	DROPDOWN_SetAutoScroll(hItem, 1);
	DROPDOWN_SetListHeight(hItem, 100);
	DROPDOWN_SetScrollbarWidth(hItem, 16);

	hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_1);
	DROPDOWN_SetFont(hItem, GUI_FONT_24B_ASCII);
	DROPDOWN_AddString(hItem, "1");
	DROPDOWN_AddString(hItem, "2");
	DROPDOWN_AddString(hItem, "3");
	DROPDOWN_AddString(hItem, "4");
	DROPDOWN_AddString(hItem, "5");
	DROPDOWN_AddString(hItem, "6");
	DROPDOWN_AddString(hItem, "7");
	DROPDOWN_AddString(hItem, "8");
	DROPDOWN_AddString(hItem, "9");
	DROPDOWN_AddString(hItem, "10");
	DROPDOWN_AddString(hItem, "11");
	DROPDOWN_AddString(hItem, "12");

	
	DROPDOWN_SetAutoScroll(hItem, 1);
	DROPDOWN_SetListHeight(hItem, 100);
	DROPDOWN_SetScrollbarWidth(hItem, 16);

	hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_2);
	DROPDOWN_SetFont(hItem, GUI_FONT_24B_ASCII);
	DROPDOWN_AddString(hItem, "1");
	DROPDOWN_AddString(hItem, "2");
	DROPDOWN_AddString(hItem, "3");
	DROPDOWN_AddString(hItem, "4");
	DROPDOWN_AddString(hItem, "5");
	DROPDOWN_AddString(hItem, "6");
	DROPDOWN_AddString(hItem, "7");
	DROPDOWN_AddString(hItem, "8");
	DROPDOWN_AddString(hItem, "9");
	DROPDOWN_AddString(hItem, "10");
	DROPDOWN_AddString(hItem, "11");
	DROPDOWN_AddString(hItem, "12");
	DROPDOWN_AddString(hItem, "13");
	DROPDOWN_AddString(hItem, "14");
	DROPDOWN_AddString(hItem, "15");
	DROPDOWN_AddString(hItem, "16");
	DROPDOWN_AddString(hItem, "17");
	DROPDOWN_AddString(hItem, "18");
	DROPDOWN_AddString(hItem, "19");
	DROPDOWN_AddString(hItem, "20");
	DROPDOWN_AddString(hItem, "21");
	DROPDOWN_AddString(hItem, "22");
	DROPDOWN_AddString(hItem, "23");
	DROPDOWN_AddString(hItem, "24");
	DROPDOWN_AddString(hItem, "25");
	DROPDOWN_AddString(hItem, "26");
	DROPDOWN_AddString(hItem, "27");
	DROPDOWN_AddString(hItem, "28");
	DROPDOWN_AddString(hItem, "29");
	DROPDOWN_AddString(hItem, "30");
	DROPDOWN_AddString(hItem, "31");

	
	DROPDOWN_SetAutoScroll(hItem, 1);
	DROPDOWN_SetListHeight(hItem, 100);
	DROPDOWN_SetScrollbarWidth(hItem, 16);

	hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_3);
	DROPDOWN_SetFont(hItem, GUI_FONT_24B_ASCII);
	DROPDOWN_AddString(hItem, "1");
	DROPDOWN_AddString(hItem, "2");
	DROPDOWN_AddString(hItem, "3");
	DROPDOWN_AddString(hItem, "4");
	DROPDOWN_AddString(hItem, "5");
	DROPDOWN_AddString(hItem, "6");
	DROPDOWN_AddString(hItem, "7");
	DROPDOWN_AddString(hItem, "8");
	DROPDOWN_AddString(hItem, "9");
	DROPDOWN_AddString(hItem, "10");
	DROPDOWN_AddString(hItem, "11");
	DROPDOWN_AddString(hItem, "12");

	
	DROPDOWN_SetAutoScroll(hItem, 1);
	DROPDOWN_SetListHeight(hItem, 100);
	DROPDOWN_SetScrollbarWidth(hItem, 16);

	hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_4);
	DROPDOWN_SetFont(hItem, GUI_FONT_24B_ASCII);
	DROPDOWN_AddString(hItem, "1");
	DROPDOWN_AddString(hItem, "2");
	DROPDOWN_AddString(hItem, "3");
	DROPDOWN_AddString(hItem, "4");
	DROPDOWN_AddString(hItem, "5");
	DROPDOWN_AddString(hItem, "6");
	DROPDOWN_AddString(hItem, "7");
	DROPDOWN_AddString(hItem, "8");
	DROPDOWN_AddString(hItem, "9");
	DROPDOWN_AddString(hItem, "10");
	DROPDOWN_AddString(hItem, "11");
	DROPDOWN_AddString(hItem, "12");
	DROPDOWN_AddString(hItem, "13");
	DROPDOWN_AddString(hItem, "14");
	DROPDOWN_AddString(hItem, "15");
	DROPDOWN_AddString(hItem, "16");
	DROPDOWN_AddString(hItem, "17");
	DROPDOWN_AddString(hItem, "18");
	DROPDOWN_AddString(hItem, "19");
	DROPDOWN_AddString(hItem, "20");
	DROPDOWN_AddString(hItem, "21");
	DROPDOWN_AddString(hItem, "22");
	DROPDOWN_AddString(hItem, "23");
	DROPDOWN_AddString(hItem, "24");
	DROPDOWN_AddString(hItem, "25");
	DROPDOWN_AddString(hItem, "26");
	DROPDOWN_AddString(hItem, "27");
	DROPDOWN_AddString(hItem, "28");
	DROPDOWN_AddString(hItem, "29");
	DROPDOWN_AddString(hItem, "30");
	DROPDOWN_AddString(hItem, "31");
	DROPDOWN_AddString(hItem, "32");
	DROPDOWN_AddString(hItem, "33");
	DROPDOWN_AddString(hItem, "34");
	DROPDOWN_AddString(hItem, "35");
	DROPDOWN_AddString(hItem, "36");
	DROPDOWN_AddString(hItem, "37");
	DROPDOWN_AddString(hItem, "38");
	DROPDOWN_AddString(hItem, "39");
	DROPDOWN_AddString(hItem, "40");
	DROPDOWN_AddString(hItem, "41");
	DROPDOWN_AddString(hItem, "42");
	DROPDOWN_AddString(hItem, "43");
	DROPDOWN_AddString(hItem, "44");
	DROPDOWN_AddString(hItem, "45");
	DROPDOWN_AddString(hItem, "46");
	DROPDOWN_AddString(hItem, "47");
	DROPDOWN_AddString(hItem, "48");
	DROPDOWN_AddString(hItem, "49");
	DROPDOWN_AddString(hItem, "50");
	DROPDOWN_AddString(hItem, "51");
	DROPDOWN_AddString(hItem, "52");
	DROPDOWN_AddString(hItem, "53");
	DROPDOWN_AddString(hItem, "54");
	DROPDOWN_AddString(hItem, "55");
	DROPDOWN_AddString(hItem, "56");
	DROPDOWN_AddString(hItem, "57");
	DROPDOWN_AddString(hItem, "58");
	DROPDOWN_AddString(hItem, "59");

	
	DROPDOWN_SetAutoScroll(hItem, 1);
	DROPDOWN_SetListHeight(hItem, 100);
	DROPDOWN_SetScrollbarWidth(hItem, 16);


    
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_DROPDOWN_0: // Notifications sent by 'Dropdown'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:

        break;
      case WM_NOTIFICATION_RELEASED:

        break;
      case WM_NOTIFICATION_SEL_CHANGED:
									  {
										  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
										  list_value =  DROPDOWN_GetSel(hItem);
										  Wset.year = list_value + 16;
									  }break;

      }
      break;
    case ID_DROPDOWN_1: // Notifications sent by 'Dropdown'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:

        break;
      case WM_NOTIFICATION_RELEASED:

        break;
      case WM_NOTIFICATION_SEL_CHANGED:
										{
										  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_1);
										  list_value =  DROPDOWN_GetSel(hItem);
										  Wset.month = list_value +1;
										  Debug_printf("mint:%d",Wset.month);
									  }break;
      }
      break;
    case ID_DROPDOWN_2: // Notifications sent by 'Dropdown'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:

        break;
      case WM_NOTIFICATION_RELEASED:

        break;
      case WM_NOTIFICATION_SEL_CHANGED:
										{
											  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_2);
											  list_value =  DROPDOWN_GetSel(hItem);
											  Wset.day = list_value +1;
											Debug_printf("mint:%d",Wset.day);
										}
        break;

      }
      break;
    case ID_DROPDOWN_3: // Notifications sent by 'Dropdown'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:

        break;
      case WM_NOTIFICATION_RELEASED:

        break;
      case WM_NOTIFICATION_SEL_CHANGED:
										{
											  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_3);
											  list_value =  DROPDOWN_GetSel(hItem);
											  Wset.hour = list_value +1;
											  Debug_printf("mint:%d",Wset.hour);
										}
        break;
      }
      break;
    case ID_DROPDOWN_4: // Notifications sent by 'Dropdown'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:

        break;
      case WM_NOTIFICATION_RELEASED:

        break;
      case WM_NOTIFICATION_SEL_CHANGED:
										{
											  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_4);
											  list_value =  DROPDOWN_GetSel(hItem);
											  Wset.mint = list_value +1;
											  Debug_printf("mint:%d",Wset.mint);
										}
        break;
      }
      break;
    case ID_BUTTON_0: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
	  {
		  
		                                 RTC_TimeAndDate_Set(Wset.hour,Wset.mint,Wset.year,Wset.month,Wset.day);
								
										  hProg = GUI_CreateDialogBox(_aDialogProgress, GUI_COUNTOF(_aDialogProgress), &_cbDialogProgress1, WM_HBKWIN, 0, 0); 
											GUI_MEMDEV_FadeInWindow(hProg, 500);
											WM_InvalidateWindow(hWin);
											WM_MakeModal(hProg);
											GUI_ExecCreatedDialog(hProg);
									  }
        break;
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
								  {GUI_EndDialog(hWin2,0);
								   Touch_TimeMode = 1 ;
								  OSTaskResume((OS_TCB *)&AppTaskShowBQTCB,&err);
									 
								  }	break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}


/*********************************************************************
*
*       CreateWindow2
*/
WM_HWIN CreateWindow2(void);
WM_HWIN CreateWindow2(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), _cbDialog2, WM_HBKWIN, 0, 0);
  return hWin;
}

/*********************************************************************
*
*                       主窗口创建
*
**********************************************************************
*/
void  MainWindow(void){

	 u8 i;
     hWinMain = CreateWindow2();
	/*在指定位置创建指定尺寸的ICONVIEW 小工具*/
	hWinICON = ICONVIEW_CreateEx(20, 						/* 小工具的最左像素（在父坐标中）*/
						     60, 							/* 小工具的最上像素（在父坐标中）*/
							 460,    						/* 小工具的水平尺寸（单位：像素）*/
							 230, 							/* 小工具的垂直尺寸（单位：像素）*/
	                         hWinMain, 				        /* 父窗口的句柄。如果为0 ，则新小工具将成为桌面（顶级窗口）的子窗口 */
							 WM_CF_SHOW | WM_CF_HASTRANS,   /* 窗口创建标记。为使小工具立即可见，通常使用 WM_CF_SHOW */ 
	                         0,//ICONVIEW_CF_AUTOSCROLLBAR_V	/* 默认是0，如果不够现实可设置增减垂直滚动条 */
							 GUI_ID_ICONVIEW0, 			        /* 小工具的窗口ID */
							 60, 				    			/* 图标的水平尺寸 */
							 60);	
	
	/* 向ICONVIEW 小工具添加新图标 */
	for (i = 0; i < GUI_COUNTOF(_aBitmapItem); i++) 
	{	
		ICONVIEW_AddBitmapItem(hWinICON, _aBitmapItem[i].pBitmap, _aBitmapItem[i].pText);
	}
	
	/* 设置小工具的背景色 32 位颜色值的前8 位可用于alpha混合处理效果*/
	ICONVIEW_SetBkColor(hWinICON, ICONVIEW_CI_SEL, GUI_WHITE | 0x80000000);
	
	/* 设置图标在x 或y 方向上的间距。*/
	ICONVIEW_SetSpace(hWinICON, GUI_COORD_Y, 20);
	ICONVIEW_SetSpace(hWinICON, GUI_COORD_X, 10);
	
	/* 设置对齐方式 */
	ICONVIEW_SetIconAlign(hWinICON, ICONVIEW_IA_HCENTER|ICONVIEW_IA_TOP);
	
	settime_mode = 0;
	
}




/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateWindow
*/
WM_HWIN CreateWindow(void);
WM_HWIN CreateWindow(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  settime_mode = 0;
  return hWin;
}



void MainTask(void) {

	
	/* 绘制桌面窗口的背景图片 ------------------------------------------*/
	hMempic = GUI_MEMDEV_CreateFixed(0, 
	                                 0, 
	                                 LCD_GetXSize(), 
	                                 LCD_GetYSize(), 
									 GUI_MEMDEV_HASTRANS, 
									 GUI_MEMDEV_APILIST_16, 
									 GUICC_M565);
	GUI_MEMDEV_Select(hMempic);
    GUI_JPEG_Draw(_acbeijing, sizeof(_acbeijing), 0, 0);
	
	GUI_MEMDEV_Select(0);
	
	while (1) {
//		Debug_printf("stop?\n");
		switch(settime_mode)
		{
			case 1:			
			{
				hWin2 = CreateWindow();
			}break;
			case 2:
			{
		        MainWindow();
			}break;
			default:
				break;
		}
		GUI_Delay(10);
	}
}

/*************************** End of file ****************************/
